package com.haibara.aiojjudgeservice.codesandbox.proxy;

import com.haibara.aiojjudgeservice.codesandbox.CodeSandbox;
import com.haibara.aiojmodel.model.codesandbox.ExecuteCodeRequest;
import com.haibara.aiojmodel.model.codesandbox.ExecuteCodeRespond;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class CodeSandboxProxy implements CodeSandbox {

    private final CodeSandbox codeSandbox;

    public CodeSandboxProxy(CodeSandbox codeSandbox) {
        this.codeSandbox = codeSandbox;
    }

    /**
     * 使用代码沙箱执行代码 （代理模式加强功能）
     * @param executeCodeRequest
     * @return
     */
    public ExecuteCodeRespond executeCode(ExecuteCodeRequest executeCodeRequest){
        log.info("Start execute Code");
        ExecuteCodeRespond executeCodeRespond = codeSandbox.executeCode(executeCodeRequest);
        log.info("End execute Code");
        return executeCodeRespond;
    }
}
